|
1
|
|
|
/* |
|
2
|
|
|
* Circles - Bring cloud-users closer together. |
|
3
|
|
|
* |
|
4
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
|
5
|
|
|
* later. See the COPYING file. |
|
6
|
|
|
* |
|
7
|
|
|
* @author Maxence Lange <[email protected]> |
|
8
|
|
|
* @copyright 2017 |
|
9
|
|
|
* @license GNU AGPL version 3 or any later version |
|
10
|
|
|
* |
|
11
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
12
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
13
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
14
|
|
|
* License, or (at your option) any later version. |
|
15
|
|
|
* |
|
16
|
|
|
* This program is distributed in the hope that it will be useful, |
|
17
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19
|
|
|
* GNU Affero General Public License for more details. |
|
20
|
|
|
* |
|
21
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
22
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
23
|
|
|
* |
|
24
|
|
|
*/ |
|
25
|
|
|
|
|
26
|
|
|
/** global: OC */ |
|
27
|
|
|
/** global: OCA */ |
|
28
|
|
|
/** global: Notyf */ |
|
29
|
|
|
|
|
30
|
|
|
/** global: actions */ |
|
31
|
|
|
/** global: nav */ |
|
32
|
|
|
/** global: elements */ |
|
33
|
|
|
/** global: resultMembers */ |
|
34
|
|
|
/** global: resultGroups */ |
|
35
|
|
|
/** global: resultCircles */ |
|
36
|
|
|
/** global: curr */ |
|
37
|
|
|
/** global: api */ |
|
38
|
|
|
/** global: define */ |
|
39
|
|
|
/** global: resultLinks */ |
|
40
|
|
|
/** global: settings */ |
|
41
|
|
|
|
|
42
|
|
|
|
|
43
|
|
|
var actions = { |
|
44
|
|
|
|
|
45
|
|
|
|
|
46
|
|
|
changeMemberLevel: function (member, level) { |
|
47
|
|
|
if (parseInt(level) === define.levelOwner) { |
|
48
|
|
|
actions.changeMemberOwner(member); |
|
49
|
|
|
return; |
|
50
|
|
|
} |
|
51
|
|
|
api.levelMember(curr.circle, member, level, resultMembers.levelMemberResult); |
|
52
|
|
|
nav.circlesActionReturn(); |
|
53
|
|
|
}, |
|
54
|
|
|
|
|
55
|
|
|
|
|
56
|
|
|
changeGroupLevel: function (group, level) { |
|
57
|
|
|
|
|
58
|
|
|
if (level === 'remove_group') { |
|
59
|
|
|
api.unlinkGroup(curr.circle, group, resultGroups.unlinkGroupResult); |
|
60
|
|
|
} else { |
|
61
|
|
|
api.levelGroup(curr.circle, group, level, resultGroups.levelGroupResult); |
|
62
|
|
|
} |
|
63
|
|
|
nav.circlesActionReturn(); |
|
64
|
|
|
}, |
|
65
|
|
|
|
|
66
|
|
|
|
|
67
|
|
|
changeMemberOwner: function (member) { |
|
68
|
|
|
OC.dialogs.confirm( |
|
69
|
|
|
t('circles', 'Are you sure you want to transfer your ownership?', [member]), |
|
70
|
|
|
t('circles', 'This action is irreversible'), |
|
71
|
|
|
function (e) { |
|
72
|
|
|
if (e === true) { |
|
73
|
|
|
api.levelMember(curr.circle, member, define.levelOwner, |
|
74
|
|
|
resultMembers.levelMemberResult); |
|
75
|
|
|
nav.circlesActionReturn(); |
|
76
|
|
|
return; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
nav.displayMembers(''); |
|
80
|
|
|
}); |
|
81
|
|
|
}, |
|
82
|
|
|
|
|
83
|
|
|
|
|
84
|
|
|
changeMemberStatus: function (member, value) { |
|
85
|
|
|
if (value === 'remove_member' || value === 'dismiss_request') { |
|
86
|
|
|
api.removeMember(curr.circle, member, resultMembers.removeMemberResult); |
|
87
|
|
|
} |
|
88
|
|
|
if (value === 'accept_request') { |
|
89
|
|
|
api.addMember(curr.circle, member, resultMembers.addMemberResult); |
|
90
|
|
|
} |
|
91
|
|
|
}, |
|
92
|
|
|
|
|
93
|
|
|
|
|
94
|
|
|
changeLinkStatus: function (link, value) { |
|
95
|
|
|
api.linkStatus(link, value, resultLinks.linkStatusResult); |
|
96
|
|
|
}, |
|
97
|
|
|
|
|
98
|
|
|
|
|
99
|
|
|
validateEmail: function (email) { |
|
100
|
|
|
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; |
|
101
|
|
|
return re.test(email); |
|
102
|
|
|
}, |
|
103
|
|
|
|
|
104
|
|
|
selectCircle: function (circle_id) { |
|
105
|
|
|
curr.searchUser = ''; |
|
106
|
|
|
elements.addMember.val(''); |
|
107
|
|
|
elements.linkGroup.val(''); |
|
108
|
|
|
elements.linkCircle.val(''); |
|
109
|
|
|
|
|
110
|
|
|
nav.circlesActionReturn(); |
|
111
|
|
|
api.detailsCircle(circle_id, resultCircles.selectCircleResult); |
|
112
|
|
|
}, |
|
113
|
|
|
|
|
114
|
|
|
|
|
115
|
|
|
unselectCircle: function (circle_id) { |
|
116
|
|
|
elements.mainUIMembersTable.emptyTable(); |
|
117
|
|
|
elements.navigation.children(".circle[circle-id='" + circle_id + "']").remove(); |
|
118
|
|
|
elements.emptyContent.show(800); |
|
119
|
|
|
elements.mainUI.fadeOut(800); |
|
120
|
|
|
|
|
121
|
|
|
curr.circle = 0; |
|
122
|
|
|
curr.circleLevel = 0; |
|
123
|
|
|
}, |
|
124
|
|
|
|
|
125
|
|
|
|
|
126
|
|
|
saveSettings: function () { |
|
127
|
|
|
data = { |
|
|
|
|
|
|
128
|
|
|
circle_name: elements.settingsName.val(), |
|
129
|
|
|
circle_desc: elements.settingsDesc.val(), |
|
130
|
|
|
allow_links: (elements.settingsLink.is(":checked")), |
|
131
|
|
|
allow_links_auto: (elements.settingsLinkAuto.is(":checked")), |
|
132
|
|
|
allow_links_files: (elements.settingsLinkFiles.is(":checked")) |
|
133
|
|
|
}; |
|
134
|
|
|
|
|
135
|
|
|
api.settingsCircle(curr.circle, data, settings.saveSettingsResult); |
|
136
|
|
|
}, |
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* |
|
140
|
|
|
* @param search |
|
141
|
|
|
*/ |
|
142
|
|
|
searchMembersRequest: function (search) { |
|
143
|
|
|
|
|
144
|
|
|
if (curr.searchUser === search) { |
|
145
|
|
|
return; |
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
|
|
curr.searchUser = search; |
|
149
|
|
|
|
|
150
|
|
|
$.get(OC.linkToOCS('apps/files_sharing/api/v1', 1) + 'sharees', |
|
151
|
|
|
{ |
|
152
|
|
|
format: 'json', |
|
153
|
|
|
search: search, |
|
154
|
|
|
perPage: 200, |
|
155
|
|
|
itemType: 'principals' |
|
156
|
|
|
}, resultMembers.searchMembersResult); |
|
157
|
|
|
}, |
|
158
|
|
|
|
|
159
|
|
|
|
|
160
|
|
|
/** |
|
161
|
|
|
* |
|
162
|
|
|
* @param search |
|
163
|
|
|
*/ |
|
164
|
|
|
searchGroupsRequest: function (search) { |
|
165
|
|
|
|
|
166
|
|
|
if (curr.searchGroup === search) { |
|
167
|
|
|
return; |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
curr.searchGroup = search; |
|
171
|
|
|
|
|
172
|
|
|
$.get(OC.linkToOCS('apps/files_sharing/api/v1', 1) + 'sharees', |
|
173
|
|
|
{ |
|
174
|
|
|
format: 'json', |
|
175
|
|
|
search: search, |
|
176
|
|
|
perPage: 200, |
|
177
|
|
|
itemType: 'principals' |
|
178
|
|
|
}, resultGroups.searchGroupsResult); |
|
179
|
|
|
}, |
|
180
|
|
|
|
|
181
|
|
|
|
|
182
|
|
|
getStringTypeFromType: function (type) { |
|
183
|
|
|
|
|
184
|
|
|
switch (Number(type)) { |
|
|
|
|
|
|
185
|
|
|
case define.typePersonal: |
|
186
|
|
|
return t('circles', 'Personal circle'); |
|
187
|
|
|
case define.typeSecret: |
|
188
|
|
|
return t('circles', 'Secret circle'); |
|
189
|
|
|
case define.typeClosed: |
|
190
|
|
|
return t('circles', 'Closed circle'); |
|
191
|
|
|
case define.typePublic: |
|
192
|
|
|
return t('circles', 'Public circle'); |
|
193
|
|
|
} |
|
194
|
|
|
|
|
195
|
|
|
return t('circles', 'Circle'); |
|
196
|
|
|
}, |
|
197
|
|
|
|
|
198
|
|
|
|
|
199
|
|
|
/** |
|
200
|
|
|
* |
|
201
|
|
|
*/ |
|
202
|
|
|
onEventNewCircle: function () { |
|
203
|
|
|
curr.circle = 0; |
|
204
|
|
|
curr.circleLevel = 0; |
|
205
|
|
|
|
|
206
|
|
|
elements.circlesList.children('div').removeClass('selected'); |
|
207
|
|
|
elements.emptyContent.show(800); |
|
208
|
|
|
elements.mainUI.fadeOut(800); |
|
209
|
|
|
}, |
|
210
|
|
|
|
|
211
|
|
|
|
|
212
|
|
|
/** |
|
213
|
|
|
* |
|
214
|
|
|
*/ |
|
215
|
|
|
onEventNewCircleName: function () { |
|
216
|
|
|
this.onEventNewCircle(); |
|
217
|
|
|
nav.displayOptionsNewCircle((elements.newName.val() !== '')); |
|
218
|
|
|
}, |
|
219
|
|
|
|
|
220
|
|
|
|
|
221
|
|
|
/** |
|
222
|
|
|
* |
|
223
|
|
|
*/ |
|
224
|
|
|
onEventNewCircleType: function () { |
|
225
|
|
|
this.onEventNewCircle(); |
|
226
|
|
|
elements.newTypeDefinition.children('div').fadeOut(300); |
|
227
|
|
|
var selectedType = elements.newType.children('option:selected').val(); |
|
228
|
|
|
if (selectedType === '') { |
|
229
|
|
|
elements.newType.addClass('select_none'); |
|
230
|
|
|
} |
|
231
|
|
|
else { |
|
232
|
|
|
elements.newType.removeClass('select_none'); |
|
233
|
|
|
$('#circles_new_type_' + selectedType).fadeIn( |
|
234
|
|
|
300); |
|
235
|
|
|
} |
|
236
|
|
|
} |
|
237
|
|
|
|
|
238
|
|
|
|
|
239
|
|
|
}; |
|
240
|
|
|
|